<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="u" uri="/iuie-tag"%>
<%@ taglib prefix="sys" uri="/sys-tag" %>
<%@ taglib prefix="lui" tagdir="/WEB-INF/tags" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>编辑字段</title>
</head>
<lui:context/>
<u:View basePath="/res-datum/development" userJS="addField" userCSS="addField" delayLoadJs="false">
<body>
<lui:dialogBody>
	<form id="editFieldFrm" class='m-cust'>
		<sys:dropCodeSet codeTypes="fieldType" id="codeSet"/>
		<div class="form-group row m-narrow">
			<div class="col-sm-12 col-md-12 col-xs-12">
			    <div class="col-sm-3 col-md-3 col-xs-3">
				    <label for="fieldName" class="m-label required">字段名称：</label>
			    </div>
			    <div class="col-sm-9 col-md-9 col-xs-9">
				    <input name="fieldName" id="fieldName" class="form-control m-input" data-validate="true" data-0-regexp="^[a-zA-Z_][a-zA-Z0-9_]{1,32}$"
				    	data-not-empty="true" data-empty-text="字段名称不能为空！" data-prompt="dialog"
				    	data-0-errorText="格式不合法<br>格式：以英文26个字母开头，大小写随意，内容仅能为26个英文字母或下划线">
			    </div>
		    </div>
		</div>
		<div class="form-group row m-narrow">
			<div class="col-sm-12 col-md-12 col-xs-12">
			    <div class="col-sm-3 col-md-3 col-xs-3">
				    <label for="fieldType" class="m-label required">字段类型：</label>
			    </div>
			    <div class="col-sm-9 col-md-9 col-xs-9">
				    <lui:dropList id="fieldType" dropValues="codeSet.fieldType" name="fieldType" className="form-control m-input"/>
			    </div>
		    </div>
		</div>
		<div class="form-group row m-narrow">
			<div class="col-sm-12 col-md-12 col-xs-12">
			    <div class="col-sm-3 col-md-3 col-xs-3">
				    <label class="m-label required">是否主键：</label>
			    </div>
			    <div class="col-sm-9 col-md-9 col-xs-9">
				    <label for="isPrimaryKeyYes" class="m-label m-radio"><input name="isPrimaryKey" id="isPrimaryKeyYes" 
						class="m-input" type="radio" value="1" onchange="AddFieldPage.onPrimaryKeyValueChanged(this)">是</label><label for="isPrimaryKeyNo" 
						class="m-input m-radio"><input name="isPrimaryKey" 
						id="isPrimaryKeyNo" type="radio" value="0" class="m-input" checked="checked">否</label>
			    </div>
		    </div>
		</div>
		<div class="form-group row m-narrow">
			<div class="col-sm-12 col-md-12 col-xs-12">
			    <div class="col-sm-3 col-md-3 col-xs-3">
				    <label class="m-label required">允许空值：</label>
			    </div>
			    <div class="col-sm-9 col-md-9 col-xs-9">
				    <label for="allowNullYes" class="m-label m-radio"><input name="allowNull" id="allowNullYes" checked="checked" 
						class="m-input" type="radio" value="1">允许</label><label for="allowNullNo" class="m-label m-radio"><input name="allowNull" 
						id="allowNullNo" type="radio" value="0" class="m-input" onchange="AddFieldPage.onPrimaryKeyValueChanged(this)">不允许</label>
			    </div>
		    </div>
		</div>
		<div class="form-group row m-narrow">
			<div class="col-sm-12 col-md-12 col-xs-12">
			    <div class="col-sm-3 col-md-3 col-xs-3">
				    <label for="fieldLength" class="m-label">字段长度：</label>
			    </div>
			    <div class="col-sm-9 col-md-9 col-xs-9">
				    <input name="fieldLength" type="number" id="fieldLength" class="form-control m-input" data-validate="true"
				    	data-0-validate-func="AddFieldPage.validateLength(this)" value="255">
			    </div>
		    </div>
		</div>
		<div class="form-group row m-narrow">
			<div class="col-sm-12 col-md-12 col-xs-12">
			    <div class="col-sm-3 col-md-3 col-xs-3">
				    <label for="display" class="m-label">DISPLAY：</label>
			    </div>
			    <div class="col-sm-9 col-md-9 col-xs-9">
				    <input name="display" id="display" class="form-control m-input" maxlength="128">
			    </div>
		    </div>
		</div>
		<div class="form-group row m-narrow">
			<div class="col-sm-12 col-md-12 col-xs-12">
			    <div class="col-sm-3 col-md-3 col-xs-3">
				    <label for="comment" class="m-label">注释：</label>
			    </div>
			    <div class="col-sm-9 col-md-9 col-xs-9">
				    <textarea name="comment" id="comment" rows="1" class="form-control m-input"></textarea>
			    </div>
		    </div>
		</div>
		<c:if test="${not empty requestScope.id }">
			<div class="form-group row m-narrow">
				<div class="col-sm-12 col-md-12 col-xs-12">
				    <div class="col-sm-3 col-md-3 col-xs-3">
					    <label for="updateRemark" class="m-label required">更新备注：</label>
				    </div>
				    <div class="col-sm-9 col-md-9 col-xs-9">
					    <textarea name="updateRemark" rows="1" class="form-control m-input" data-validate="true" data-not-empty="true" 
					    	data-empty-text="更新备注不能为空！" data-prompt="dialog" maxlength="200"></textarea>
				    </div>
			    </div>
			</div>
		</c:if>
		<input hidden="hidden" name="id">
		<input hidden="hidden" name="tableId" value="${requestScope.tableId }">
		<c:if test="${not empty requestScope.id }">
			<lui:ajax id="findFieldAjax" url="${ctx }/datum/development/find/field/id/${requestScope.id }" autoSend="true"
				onSuccess="AddFieldPage.onFindFieldSucc"/>
		</c:if>
		<lui:ajax id="saveFieldAjax" url="${ctx }/datum/development/save/field" onSuccess="AddFieldPage.saveSucc" formQuery="#editFieldFrm"
			formSubmit="true" type="post" contentType="application/x-www-form-urlencoded" />
	</form>
</lui:dialogBody>
<lui:dialogFooter>
	<button class="btn btn-primary m-btn" type="button" onclick="AddFieldPage.save()">保存</button>
	<button class="btn btn-default m-btn" type="button" data-dismiss="dialog-box">关闭</button>
</lui:dialogFooter>
</body>
</u:View>
</html>